/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Consultar.java
 *
 * Created on 02/11/2011, 12:00:14
 */
package Interfaces;

import classes.Agenda;
import classes.AreaTematica;
import classes.EventoPrincipal;
import classes.Minicurso;
import conexaoBD.mySQLcrud;
import java.awt.Color;
import java.awt.Dimension;
import java.security.Timestamp;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import javax.swing.JOptionPane;
import javax.swing.ListModel;

/**
 *
 * @author Kazuo
 */
public class TelaExibicaoMiniCurso extends javax.swing.JFrame {

    private mySQLcrud connectionCrud;
    private ArrayList<EventoPrincipal> listaEventosPrincipal;
    private ArrayList<AreaTematica> areaTema;
    Dimension s = new Dimension(59, 20);
    Dimension s2 = new Dimension(120, 20);

    //teste
    /** Creates new form Consultar */
    public TelaExibicaoMiniCurso(String codigo) {
        connectionCrud = new mySQLcrud();
        initComponents();

        cbEventoPrincipal.setPreferredSize(s);
        cbAreaCiencia.setPreferredSize(s);
        txtNumVagas.setPreferredSize(s);
        jDateInicio.setPreferredSize(s);
        jDateTermino.setPreferredSize(s);
        txtDescricao.setPreferredSize(s2);
        txtNome.setPreferredSize(s2);

        ArrayList<Minicurso> exibe = new ArrayList<Minicurso>();
        exibe = connectionCrud.listaMinicurso("");
        preencheTabelaExibicao(exibe, Integer.parseInt(codigo));

        areaTema = connectionCrud.listaAreaTematica("");
        preencherComboBoxEventoPrincipal();
        preencherComboBoxAreaCiencia();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        java.awt.GridBagConstraints gridBagConstraints;

        buttonGroup1 = new javax.swing.ButtonGroup();
        jPanel1 = new javax.swing.JPanel();
        lblTitulo = new javax.swing.JLabel();
        lblParamConsulta = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        lblNome = new javax.swing.JLabel();
        txtNome = new javax.swing.JTextField();
        lblNumVagas = new javax.swing.JLabel();
        txtNumVagas = new javax.swing.JTextField();
        cbAreaCiencia = new javax.swing.JComboBox();
        cbEventoPrincipal = new javax.swing.JComboBox();
        cbTema = new javax.swing.JComboBox();
        lblTema = new javax.swing.JLabel();
        lblAreaCiencia = new javax.swing.JLabel();
        lblEventoPrincipal = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        listRecursos = new javax.swing.JList();
        jScrollPane2 = new javax.swing.JScrollPane();
        listPalestrantes = new javax.swing.JList();
        btRecursos = new javax.swing.JButton();
        btPalestrantes = new javax.swing.JButton();
        lblDataInicio = new javax.swing.JLabel();
        lblDataTermino = new javax.swing.JLabel();
        btConfirmar1 = new javax.swing.JButton();
        btCancelar = new javax.swing.JButton();
        btConfirmar = new javax.swing.JButton();
        lblDescricao = new javax.swing.JLabel();
        txtDescricao = new javax.swing.JTextField();
        jDateInicio = new com.toedter.calendar.JDateChooser();
        jDateTermino = new com.toedter.calendar.JDateChooser();
        jLabel1 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        lblTitulo.setFont(new java.awt.Font("Tahoma", 1, 14));
        lblTitulo.setText("Dados do");
        jPanel1.add(lblTitulo);

        lblParamConsulta.setFont(new java.awt.Font("Tahoma", 1, 16));
        lblParamConsulta.setText("Mini-Curso");
        jPanel1.add(lblParamConsulta);

        jPanel2.setLayout(new java.awt.GridBagLayout());

        lblNome.setText("Nome:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
        gridBagConstraints.insets = new java.awt.Insets(0, 5, 0, 5);
        jPanel2.add(lblNome, gridBagConstraints);

        txtNome.setToolTipText("Digite o nome do Mini-Curso");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.ipadx = 153;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        jPanel2.add(txtNome, gridBagConstraints);

        lblNumVagas.setText("Número de Vagas:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 3;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
        gridBagConstraints.insets = new java.awt.Insets(0, 5, 0, 5);
        jPanel2.add(lblNumVagas, gridBagConstraints);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 3;
        gridBagConstraints.gridy = 3;
        gridBagConstraints.ipadx = 153;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        jPanel2.add(txtNumVagas, gridBagConstraints);

        cbAreaCiencia.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                cbAreaCienciaItemStateChanged(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 5;
        gridBagConstraints.ipadx = 103;
        gridBagConstraints.insets = new java.awt.Insets(10, 0, 10, 0);
        jPanel2.add(cbAreaCiencia, gridBagConstraints);

        cbEventoPrincipal.setToolTipText("Selecione o evento que se encontra o Mini-Curso");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 3;
        gridBagConstraints.ipadx = 103;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        jPanel2.add(cbEventoPrincipal, gridBagConstraints);

        cbTema.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        cbTema.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                cbTemaItemStateChanged(evt);
            }
        });
        cbTema.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                cbTemaKeyTyped(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 3;
        gridBagConstraints.gridy = 5;
        gridBagConstraints.ipadx = 103;
        gridBagConstraints.insets = new java.awt.Insets(10, 0, 10, 0);
        jPanel2.add(cbTema, gridBagConstraints);

        lblTema.setText("Tema:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 5;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
        gridBagConstraints.insets = new java.awt.Insets(10, 5, 10, 5);
        jPanel2.add(lblTema, gridBagConstraints);

        lblAreaCiencia.setText("Área da Ciência:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 5;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
        gridBagConstraints.insets = new java.awt.Insets(10, 5, 10, 5);
        jPanel2.add(lblAreaCiencia, gridBagConstraints);

        lblEventoPrincipal.setText("Evento Principal:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 3;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
        gridBagConstraints.insets = new java.awt.Insets(0, 5, 0, 5);
        jPanel2.add(lblEventoPrincipal, gridBagConstraints);

        listRecursos.setModel(new javax.swing.AbstractListModel() {
            String[] strings = { " ", " ", " ", " ", " ", " ", " " };
            public int getSize() { return strings.length; }
            public Object getElementAt(int i) { return strings[i]; }
        });
        listRecursos.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        jScrollPane1.setViewportView(listRecursos);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 10;
        gridBagConstraints.ipadx = 120;
        jPanel2.add(jScrollPane1, gridBagConstraints);

        listPalestrantes.setModel(new javax.swing.AbstractListModel() {
            String[] strings = { " ", " ", " ", " ", " ", " " };
            public int getSize() { return strings.length; }
            public Object getElementAt(int i) { return strings[i]; }
        });
        listPalestrantes.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        jScrollPane2.setViewportView(listPalestrantes);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 10;
        gridBagConstraints.gridwidth = 2;
        gridBagConstraints.ipadx = 120;
        jPanel2.add(jScrollPane2, gridBagConstraints);

        btRecursos.setText("Editar Recursos");
        btRecursos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btRecursosActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 9;
        gridBagConstraints.insets = new java.awt.Insets(8, 0, 8, 0);
        jPanel2.add(btRecursos, gridBagConstraints);

        btPalestrantes.setText("Editar Palestrantes");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 9;
        gridBagConstraints.gridwidth = 2;
        jPanel2.add(btPalestrantes, gridBagConstraints);

        lblDataInicio.setText("Data de Início:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
        gridBagConstraints.insets = new java.awt.Insets(0, 5, 0, 5);
        jPanel2.add(lblDataInicio, gridBagConstraints);

        lblDataTermino.setText("Data de Término:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
        gridBagConstraints.insets = new java.awt.Insets(0, 5, 0, 5);
        jPanel2.add(lblDataTermino, gridBagConstraints);

        btConfirmar1.setText("Salvar Alterações");
        btConfirmar1.setToolTipText("Salvar alterações do Mini-Curso");
        btConfirmar1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btConfirmar1ActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 12;
        gridBagConstraints.insets = new java.awt.Insets(15, 0, 0, 0);
        jPanel2.add(btConfirmar1, gridBagConstraints);

        btCancelar.setText("Remover Mini-Curso");
        btCancelar.setToolTipText("Clique aqui para remover o Mini-Curso");
        btCancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btCancelarActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 12;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
        gridBagConstraints.insets = new java.awt.Insets(15, 0, 0, 0);
        jPanel2.add(btCancelar, gridBagConstraints);

        btConfirmar.setText("Cancelar");
        btConfirmar.setToolTipText("Cancelar e retornar para a tela anterior");
        btConfirmar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btConfirmarActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 3;
        gridBagConstraints.gridy = 12;
        gridBagConstraints.insets = new java.awt.Insets(15, 0, 0, 0);
        jPanel2.add(btConfirmar, gridBagConstraints);

        lblDescricao.setText("Descrição:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
        gridBagConstraints.insets = new java.awt.Insets(0, 5, 0, 5);
        jPanel2.add(lblDescricao, gridBagConstraints);

        txtDescricao.setToolTipText("Digite o nome do Mini-Curso");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.gridwidth = 3;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.ipadx = 153;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        jPanel2.add(txtDescricao, gridBagConstraints);

        jDateInicio.setPreferredSize(new java.awt.Dimension(56, 20));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.ipadx = 12;
        jPanel2.add(jDateInicio, gridBagConstraints);

        jDateTermino.setPreferredSize(new java.awt.Dimension(56, 20));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 3;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        jPanel2.add(jDateTermino, gridBagConstraints);

        jLabel1.setForeground(new java.awt.Color(255, 0, 0));
        jLabel1.setText("Atenção: Todos os campos são obrigatórios!");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 3;
        gridBagConstraints.gridy = 0;
        jPanel2.add(jLabel1, gridBagConstraints);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 878, Short.MAX_VALUE)
            .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, 878, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, 376, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btConfirmarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btConfirmarActionPerformed
        this.setVisible(false);
    }//GEN-LAST:event_btConfirmarActionPerformed

    private void btConfirmar1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btConfirmar1ActionPerformed
        HashMap<Integer, Object> listaCampos = new HashMap<Integer, Object>();
        if (verificaCampos(listaCampos)) {
            JOptionPane.showMessageDialog(null, "Alterações realiazdas com sucesso");
            this.dispose();
        }
    }//GEN-LAST:event_btConfirmar1ActionPerformed

    private void btCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btCancelarActionPerformed
        JOptionPane.showMessageDialog(null, "Remoção realiazda com sucesso");
        this.setVisible(false);
    }//GEN-LAST:event_btCancelarActionPerformed

    private void cbTemaKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_cbTemaKeyTyped
        // TODO add your handling code here:
    }//GEN-LAST:event_cbTemaKeyTyped

    private void cbTemaItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cbTemaItemStateChanged
    }//GEN-LAST:event_cbTemaItemStateChanged

    private void cbAreaCienciaItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cbAreaCienciaItemStateChanged
        String itemSelecionado = (String) cbAreaCiencia.getSelectedItem();
        if (!itemSelecionado.equals("Selecione a area da ciência")) {
            preencherComboBoxAreaTema(itemSelecionado);
        }
    }//GEN-LAST:event_cbAreaCienciaItemStateChanged

    private void btRecursosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btRecursosActionPerformed
        // TODO add your handling code here:

               TelaAdicionarRecursos t = new TelaAdicionarRecursos();
        t.setFormilario(this);
        t.setVisible(true);
    }//GEN-LAST:event_btRecursosActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new TelaConsulta().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btCancelar;
    private javax.swing.JButton btConfirmar;
    private javax.swing.JButton btConfirmar1;
    private javax.swing.JButton btPalestrantes;
    private javax.swing.JButton btRecursos;
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.JComboBox cbAreaCiencia;
    private javax.swing.JComboBox cbEventoPrincipal;
    private javax.swing.JComboBox cbTema;
    private com.toedter.calendar.JDateChooser jDateInicio;
    private com.toedter.calendar.JDateChooser jDateTermino;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JLabel lblAreaCiencia;
    private javax.swing.JLabel lblDataInicio;
    private javax.swing.JLabel lblDataTermino;
    private javax.swing.JLabel lblDescricao;
    private javax.swing.JLabel lblEventoPrincipal;
    private javax.swing.JLabel lblNome;
    private javax.swing.JLabel lblNumVagas;
    private javax.swing.JLabel lblParamConsulta;
    private javax.swing.JLabel lblTema;
    private javax.swing.JLabel lblTitulo;
    private javax.swing.JList listPalestrantes;
    private javax.swing.JList listRecursos;
    private javax.swing.JTextField txtDescricao;
    private javax.swing.JTextField txtNome;
    private javax.swing.JTextField txtNumVagas;
    // End of variables declaration//GEN-END:variables

    private boolean verificaCampos(HashMap<Integer, Object> campos) {

        String nome = txtNome.getText();
        String descricao = txtDescricao.getText();
        Date dataInicio = jDateInicio.getDate();
        Date dataTermino = jDateInicio.getDate();
        ListModel listaRecursos = listRecursos.getModel();
        ListModel listaPalestrante = listPalestrantes.getModel();

        if (nome.equals("") || nome.trim().equals("")) {
            lblNome.setForeground(Color.red);
            txtNome.setText("");
            txtNome.grabFocus();
            JOptionPane.showMessageDialog(null, "Preencha o nome do mini curso corretamente");
            return false;
        } else {
            lblNome.setForeground(Color.black);
            if (descricao.equals("") || descricao.trim().equals("")) {
                lblDescricao.setForeground(Color.red);
                txtDescricao.setText("");
                txtDescricao.grabFocus();
                JOptionPane.showMessageDialog(null, "Preencha a descrição do mini curso corretamente");
                return false;
            } else {
                lblDescricao.setForeground(Color.black);
                if (txtNumVagas.getText().equals("") || !txtNumVagas.getText().matches("^[0-9]*$")) {
                    lblNumVagas.setForeground(Color.red);
                    txtNumVagas.setText("");
                    txtNumVagas.grabFocus();
                    JOptionPane.showMessageDialog(null, "Preencha a quantidade de vagas do mini curso corretamente");
                    return false;
                } else {
                    if (!txtNumVagas.getText().matches("^[0-9]*$")) {
                        lblNumVagas.setForeground(Color.red);
                        txtNumVagas.setText("");
                        txtNumVagas.grabFocus();
                        JOptionPane.showMessageDialog(null, "Preencha a quantidade de vagas do mini curso corretamente (SOMENTE NÚMEROS)");
                        return false;
                    } else {
                        lblEventoPrincipal.setForeground(Color.black);
                        if (dataInicio == null) {
                            lblDataInicio.setForeground(Color.red);
                            JOptionPane.showMessageDialog(null, "Selecione uma data de inicio");
                            return false;
                        } else {
                            lblDataInicio.setForeground(Color.black);
                            if (dataTermino == null) {
                                lblDataTermino.setForeground(Color.red);
                                JOptionPane.showMessageDialog(null, "Selecione uma data de temino");
                                return false;
                            } else {
                                lblTema.setForeground(Color.black);
                                if (listaPalestrante.getSize() == 0) {
                                    btPalestrantes.setForeground(Color.red);
                                    JOptionPane.showMessageDialog(null, "Selecione um palestrante");
                                    return false;
                                } else {
                                    btPalestrantes.setForeground(Color.black);
                                    return true;
                                }
                            }
                        }
                    }
                }
            }
        }

    }

    private void preencheTabelaExibicao(ArrayList<Minicurso> exibe, Integer codigo) {
        ArrayList<Minicurso> listaMiniCurso = new ArrayList<Minicurso>();
        int indice = 0;
        for (Object o : exibe) {
            listaMiniCurso.add((Minicurso) o);
        }
        for (int i = 0; i < exibe.size(); i++) {
            if (listaMiniCurso.get(i).getCodMinicurso() == codigo) {
                indice = i;
            }
        }
        txtNome.setText(listaMiniCurso.get(indice).getNomeMinicurso());
        txtDescricao.setText(listaMiniCurso.get(indice).getDescricaoMinicurso());
        txtNumVagas.setText((Integer.toString(listaMiniCurso.get(indice).getNumTotalVagas())));

        int codigoAgenda = listaMiniCurso.get(indice).getCodAgenda();
        ArrayList<Agenda> ag;
        ag = connectionCrud.listaAgenda(codigoAgenda);
        jDateInicio.setDate(ag.get(0).getDataInicio());
        jDateTermino.setDate(ag.get(0).getDataTermino());
    }

    private void preencherComboBoxAreaCiencia() {
        ArrayList<String> jaInserido = new ArrayList<String>();
        cbAreaCiencia.addItem("Selecione a area da ciência");
        for (AreaTematica a : areaTema) {
            if (!jaInserido.contains(a.getAreaCiencia())) {
                cbAreaCiencia.addItem(a.getAreaCiencia());
                jaInserido.add(a.getAreaCiencia());
            }
        }
    }

    private void preencherComboBoxAreaTema(String areaSelecionada) {
        cbTema.removeAllItems();
        if (!areaSelecionada.equals("Selecione a area da ciência")) {
            for (AreaTematica a : areaTema) {
                if (a.getAreaCiencia().equals(areaSelecionada)) {
                    cbTema.addItem(a.getTema());
                    cbTema.setPreferredSize(s);
                }
            }
        }

    }

    private void preencherComboBoxEventoPrincipal() {
        listaEventosPrincipal = connectionCrud.listaEventoPrincipal("");
        for (EventoPrincipal a : listaEventosPrincipal) {
            cbEventoPrincipal.addItem(a.getNomeEventoPrincipal());
        }
    }
}
